/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewWeblogPanel.java
 *
 * Created on Feb 25, 2011, 8:35:42 AM
 */

package com.remoteblogger.blogeditor;

import com.remoteblogger.wordpress.WPGlobalUser;

/**
 *
 * @author prasath
 */
public class NewWeblogPanel extends javax.swing.JPanel {

    /** Creates new form NewWeblogPanel */
    public NewWeblogPanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        userNameField = new javax.swing.JTextField();
        userNameLabel = new javax.swing.JLabel();
        passwordLabel = new javax.swing.JLabel();
        PasswordField = new javax.swing.JPasswordField();
        urlLabel = new javax.swing.JLabel();
        urlField = new javax.swing.JTextField();

        userNameField.setText(org.openide.util.NbBundle.getMessage(NewWeblogPanel.class, "NewWeblogPanel.userNameField.text")); // NOI18N

        userNameLabel.setText(org.openide.util.NbBundle.getMessage(NewWeblogPanel.class, "NewWeblogPanel.userNameLabel.text")); // NOI18N

        passwordLabel.setText(org.openide.util.NbBundle.getMessage(NewWeblogPanel.class, "NewWeblogPanel.passwordLabel.text")); // NOI18N

        PasswordField.setText(org.openide.util.NbBundle.getMessage(NewWeblogPanel.class, "NewWeblogPanel.PasswordField.text")); // NOI18N

        urlLabel.setText(org.openide.util.NbBundle.getMessage(NewWeblogPanel.class, "NewWeblogPanel.urlLabel.text")); // NOI18N

        urlField.setText(org.openide.util.NbBundle.getMessage(NewWeblogPanel.class, "NewWeblogPanel.urlField.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(67, 67, 67)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(urlLabel)
                    .addComponent(passwordLabel)
                    .addComponent(userNameLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(urlField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                    .addComponent(PasswordField)
                    .addComponent(userNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(67, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {PasswordField, urlField, userNameField});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(userNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(userNameLabel))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwordLabel)
                    .addComponent(PasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(urlField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(urlLabel))
                .addContainerGap(59, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {PasswordField, urlField, userNameField});

    }// </editor-fold>//GEN-END:initComponents


    public void  createWeblog() {       
        //assigning a blog for the global user
        WPGlobalUser.getInstance().addClient(userNameField.getText(),new String(PasswordField.getPassword()),urlField.getText());
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPasswordField PasswordField;
    private javax.swing.JLabel passwordLabel;
    private javax.swing.JTextField urlField;
    private javax.swing.JLabel urlLabel;
    private javax.swing.JTextField userNameField;
    private javax.swing.JLabel userNameLabel;
    // End of variables declaration//GEN-END:variables

}
